//==========================================================================
// Copyright (c) 2000-2008,  Elastos, Inc.  All Rights Reserved.
//==========================================================================

#include <elasys_server.h>
#include <elapi.h>
#include <driver.h>
#include <VirtualDevice.h>
#include "DevicePower.h"

CVirtualDevice * g_display;//seems not good enough.
extern int IsPowerManagerNeeded;
extern"C" ECode _SysRegisterDevice(wchar_t* Name, IInterface * pObject);
extern"C" int Power_GetDeviceID(wchar_t * Name);
ECode _SysRegisterDevice(wchar_t* Name, IInterface * pObject)
{
    if (IsPowerManagerNeeded) {
        int deviceID=Power_GetDeviceID((wchar_t *)Name);
        CVirtualDevice *pidevice=new CVirtualDevice(deviceID,pObject);
        if(wcscmp((wchar_t *)Name, L"device:display0") == 0)g_display = pidevice;//handle display alone.coz it doesn't use IZFile for data transfering.
        return _CSystem_RegisterRunningObject(Name, pidevice);//replace the real device with virtual device and save the real interface pointer.
    }
    else
        return _CSystem_RegisterRunningObject(Name, pObject);
}

extern"C" ECode DM_NotifyInput()
{//not call this function when just move.
    g_display->UpdateInputLastUse();
    return NOERROR;
}
